<template>
	<div class="main">
		<div>

			<div class="ad_main">

				<view class="left_ad">
					<template v-if="wenzis.length==1">
						<a href="" @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[0].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
					<template v-else-if="wenzis.length==2">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[0].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[1].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>

					<template v-else-if="wenzis.length>=3">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[0].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[1].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(2)"><text class="tuijian_text">【推荐】</text>{{wenzis[2].GUANGGAO_CONTENT}}</a>
					</template>
					<template v-else-if="wenzis.length==0">
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>

				</view>
				<div class="search" v-show="isShowSearch">
					<view class="search_content"> <input type="text" class="search_input" v-model="searchdata"
							placeholder="请输入关键字">
						<a class="search_btn">
							<view @click="search()">搜索</view>
						</a>
					</view>

					<div class="search_tag">
						公告：<text>网站信息由用户自行发布，请自行辨别真假，一切后果由用户自行承担</text>
						
					</div>
				</div>
				
				<div class="right_ad" v-show="isShowMidAd">
					<template v-if="wenzis.length<=3">
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
					<template v-else-if="wenzis.length==4">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
					<template v-else-if="wenzis.length==5">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[4].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
				
					<template v-else-if="wenzis.length==6">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[4].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(2)"><text class="tuijian_text">【推荐】</text>{{wenzis[5].GUANGGAO_CONTENT}}</a>
					</template>
				</div>
				
				<div class="right_ad">
					<template v-if="wenzis.length<=3">
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
					<template v-else-if="wenzis.length==4">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>
					<template v-else-if="wenzis.length==5">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[4].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(-1)">--广告位招租782244031--</a>
					</template>

					<template v-else-if="wenzis.length==6">
						<a @click="addUser(0)"><text class="tuijian_text">【推荐】</text>{{wenzis[3].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(1)"><text class="tuijian_text">【推荐】</text>{{wenzis[4].GUANGGAO_CONTENT}}</a>
						<a @click="addUser(2)"><text class="tuijian_text">【推荐】</text>{{wenzis[5].GUANGGAO_CONTENT}}</a>
					</template>
				</div>
			</div>
			<div class="image_ad" v-show="isShowImageAd">
				<template v-if="tupians.length==0">
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==1">
					<img :src="tupians[0].GUANGGAO_IMGURL" @click="showad(0)"/>
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==2">
					<img :src="tupians[0].GUANGGAO_IMGURL" @click="showad(0)"/>
					<img :src="tupians[1].GUANGGAO_IMGURL" @click="showad(1)"/>
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==3">
					<img :src="tupians[0].GUANGGAO_IMGURL" @click="showad(0)"/>
					<img :src="tupians[1].GUANGGAO_IMGURL" @click="showad(1)"/>
					<img :src="tupians[2].GUANGGAO_IMGURL" @click="showad(2)"/>
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==4">
					<img :src="tupians[0].GUANGGAO_IMGURL" @click="showad(0)"/>
					<img :src="tupians[1].GUANGGAO_IMGURL" @click="showad(1)"/>
					<img :src="tupians[2].GUANGGAO_IMGURL" @click="showad(2)"/>
					<img :src="tupians[3].GUANGGAO_IMGURL" @click="showad(3)"/>
					<img src="../../../static/ads/ad1.gif" />
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==5">
					<img :src="tupians[0].GUANGGAO_IMGURL" @onclick="showad(0)"/>
					<img :src="tupians[1].GUANGGAO_IMGURL" @onclick="showad(1)"/>
					<img :src="tupians[2].GUANGGAO_IMGURL" @onclick="showad(2)"/>
					<img :src="tupians[3].GUANGGAO_IMGURL" @onclick="showad(3)"/>
					<img :src="tupians[4].GUANGGAO_IMGURL" @onclick="showad(4)"/>
					<img src="../../../static/ads/ad1.gif" />
				</template>
				<template v-if="tupians.length==6">
					<img :src="tupians[0].GUANGGAO_IMGURL" @click="showad(0)"/>
					<img :src="tupians[1].GUANGGAO_IMGURL" @click="showad(1)"/>
					<img :src="tupians[2].GUANGGAO_IMGURL" @click="showad(2)"/>
					<img :src="tupians[3].GUANGGAO_IMGURL" @click="showad(3)"/>
					<img :src="tupians[4].GUANGGAO_IMGURL" @click="showad(4)"/>
					<img :src="tupians[5].GUANGGAO_IMGURL" @click="showad(5)"/>
				</template>


			</div>
		</div>
	</div>
</template>

<script>
	import AdControl from './AdContral.js'

	export default {
		onLoad: function(option) {
			console.log("页面 onLoad");
		},
		props: {},

		data() {
			return {
				wenzis: [],
				tupians: [],
				searchdata: null,
				isShowImageAd: false,
				isShowSearch:true,
				isShowMidAd:false,
			}
		},
		mounted() {
			this.$nextTick(() => {
				this.getAds(1);
			});

		},
		updated() {
			console.log("updatedupdatedupdatedupdated");
		},
		methods: {
			addUser(index){
				 if(index==-1){
					window.location.href = "tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin=782244031" 
				 }
				 else{
					var qq=this.wenzis[index].GUANGGAO_LXQQ;
					var lianjie=this.wenzis[index].GUANGGAO_GGLJ;
					console.log(qq);
					console.log(lianjie);
					if(lianjie!=null && lianjie!=""){
						window.location.href = lianjie
					}
					else{
						window.location.href = "tencent://AddContact/?fromId=50&fromSubId=1&subcmd=all&uin="+qq
					} 
				 }
				
			},
			showad(index){
				console.log(index);
				if(index>=0){
					var lianjie=this.tupians[index].GUANGGAO_GGLJ
					console.log(lianjie);
					window.location.href = lianjie
				}
				
			},
			hidImageAd() {
				this.isShowImageAd = false;
			},
			hidSearch() {
				this.isShowSearch = false;
			},
			showMidAd() {
				this.isShowMidAd = true;
			},
			getAds() {
				var Callback = {
					showAds: (datas) => {
						this.wenzis = datas.data.wenziAds;
						this.tupians = datas.data.tupianAds;
						console.log(this.tupians.size);
					}
				}
				AdControl.getAds(Callback)
			},
			
			search(){
				if (this.searchdata == null) {
					this.$Utils.showToast("请输入关键字");
					return;
				}
				uni.$emit('showSearchData', this.searchdata);
			}

		},




	}
</script>

<style>
	a {
		text-decoration: none;
		font-size: 16px;
		color: 	#FF8C00;
		font-weight: bold;
	}

	.main {
		justify-content: center;
		display: flex;
	}

	.ad_main {
		justify-content: space-between;
		margin-top: 3.825rem;
		width: 75rem;
		height: 100px;
		display: flex;
		padding-top: 1rem;
		padding-bottom: 0.625rem;

	}

	.left_ad {
		padding-top: 5px;
		padding-bottom: 5px;
		align-items: center;
		justify-content: space-around;
		overflow: hidden;
		word-wrap: break-word;
		overflow: hidden;
		word-break: break-all;
		flex-direction: column;
		display: flex;
		flex-grow: 6;
		font-size: 15px;
		color: #FB9E00;
		width: 300px;
		border: 0.0625rem solid #E5E5E5;
		border-radius: 0.3125rem;

	}

	.search {
		flex-grow: 56;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;

	}

	.search_content {
		height: 100%;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.search_input {
		width: 450px;
		height: 45px;
		border-bottom-left-radius: 10px;
		border-top-left-radius: 10px;
		border: 1px solid #E5E5E5;
		border-right: none;
		outline: none;
		padding-left: 5px;
		font-size: 15px;
		background-color: #F1EFEE;

	}

	.tuijian_text {
		color: #FB9E00;
		font-size: 14;
	}

	.search_input:focus {
		border: 2px solid #303030;
	}

	.search_btn {
		justify-content: center;
		align-items: center;
		display: flex;
		background: #666666;
		width: 100px;
		height: 45px;
		border-bottom-right-radius: 5px;
		border-top-right-radius: 5px;
		color: white;
		outline: none;
		border: none;
		font-size: 18px;
	}

	.search_content a:hover {
		background: #F0AD4E;
	}

	.right_ad {
		padding-top: 5px;
		padding-bottom: 5px;
		align-items: center;
		justify-content: space-around;
		flex-direction: column;
		display: flex;
		flex-grow: 6;
		font-size: 15px;
		color: #FB9E00;
		width: 300px;
		border: 0.0625rem solid #E5E5E5;
		border-radius: 0.3125rem;


	}

	.search_tag {
		align-self: flex-start;
		color: #666666;
		font-size: 0.9375rem;
		margin-left: 20px;

	}

	.search_tag text {
		margin-right: 20px;
	}

	.search_tag a {
		margin-left: 1.25rem;
	}

	.image_ad {
		margin-bottom: 10px;
		padding-left: 3px;
		display: flex;
		justify-content: space-between;
		width: 1200px;
		max-height: 65px;

	}

	.image_ad image {
		display: flex;
		margin-right: 0.1875rem;
		margin-left: 0.1875rem;
		width: 38.125rem;
		max-height: 65px;
	}
</style>
